type Maybe of %a is Nothing 
  or Just(%a);

contract monad over %%m is {
  _return has type (%a) => %%m of %a;
  _bind has type (%%m of %a, (%a) => %%m of %b) => %%m of %b
  _fail has type () => %%m of %a;
  _perform has type (%%m of %a) => %a;
};

implementation monad over Maybe is {
  _return(x) is Just(x);
  _bind(m, f) is case m in {
    Nothing is Nothing;
    Just(v) is f(v);
  };
  _fail() is Nothing;
  _perform(Just(X)) is X;
};
